$(function () {
    var form = new xhForm($('#xh_form'));
    form.parse();
    form.fill(info);

    $(function () {
        getTrack();
    });


    $('#save').click(function () {
        window.top.swal({
            title:  '确认保存么？',
            showCancelButton: true,
            cancelButtonText: '取消',
            confirmButtonText: '确认',
            allowOutsideClick: true,
            showCloseButton: true,
            showLoaderOnConfirm: true,
            type: 'warning',
            preConfirm: function() {
                return new Promise(function (resolve, reject) {
                    form.submit('school_book/saveInfo',{},function (res) {
                      window.top.xhTop.showSuccess(res.msg);
                      location.reload();
                    })
                })
            }
        }).then(function(isConfirm) {}, function(dismiss) {});
    });

    $('.scrollView').eq(0).on('click','[id^=delete_]',function () {
        var id = $(this).attr("id").split("delete_")[1];
        xhExtra.askChangeStatus('school_book/delTrack',{id:id},null,'确定要删除么？',function (res) {
            window.top.xhTop.showSuccess(res.msg);
            location.reload();
        });
    });
    
});

function getTrack() {
    xhExtra.ajaxRequest('school_book/getTrack',{id:info.iSBLId},{},function (res) {
        timeLine.loadTimeLine($('#timeWraper'),res,'',true ,false);
    });
}

